<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>

    </style>
</head>

<body>
    <input type="text" name="" id="">

    <span></span>
    <br>
    <button>提交</button>
    <script>
        var password = document.querySelector("input");
        var text = document.querySelector("span");
        document.querySelector("input").addEventListener("input", function () {
            // if (password.length === 0) {
            //     text.innerHTML = "密码不可为空";
            //     text.style.color = "red";
            //     return
            // }

            // if (password.length < 3 || password.length > 6) {
            //     text.innerHTML = "密码长度不对";
            //     text.style.color = "red";
            //     return
            // }

            if (password.length >= 3 || password.value.length <= 6) {
                var num = 0;
                var upper = 0;
                var lower = 0;
                // console.log(12);


                for (var m = 0; m < password.value.length; m++) {
                    // console.log(11);
                    var x = password.value.charCodeAt(m)
                    // console.log(x);
                    // if(password>=0&&password<=9)
                    if (x >= 48 && x <= 57) {
                        // 数字
                        num = 1;
                        console.log(333);
                    } else if (x >= 65 && x <= 90) {
                        // 大写字母
                        upper = 1;
                    } else if (x >= 97 && x <= 122) {
                        // 小写字母
                        lower = 1;
                    }

                }

                var sum = num + upper + lower;
                console.log(sum);
                // console.log(sum);
                if (sum === 3) {
                    text.innerHTML = "密码强度强";
                    text.style.color = "green";
                    return
                } else if (sum === 2) {
                    text.innerHTML = "密码强度中";
                    text.style.color = "skyblue";
                    return
                } else if (sum === 1) {
                    text.innerHTML = "密码强度低";
                    text.style.color = "blueviolet";
                    return
                }
            }




        })
    </script>
</body>

</html>